<template>
	<div>
		
	</div>
</template>

<script>
import axios from 'axios'
export default {
  name: 'two',
  components: {
  },
  created(){
	//get
	axios.get('/data.json',{
		params:{
			id:100
		}
	}).then(function(res){
		console.log(res)
	})
	//get
	axios({
		method:'get',
		url:'/data.json',
		params:{
			id:150
		}
	}).then(res=>{
		console.log(res)
	})
	//post
	//application/json
	let data={
		id:120
	}
	axios.post('/post',data).then(res=>{
		console.log(res)
	})
	axios({
		method:'post',
		url:'/post',
		data:data
	}).then(res=>{
		console.log(res)
	})
	//post
	//form-data
	let formData = new FormData()
	for(let key in data){
		formData.append(key,data[key])
	}
	axios.post('/post',formData).then(res=>{
		console.log(res)
	})
	//put
	axios.put('/put',data).then(res=>{
		console.log(res)
	})
	//patch
	axios.patch('/patch',data).then(res=>{
		console.log(res)
	})
	//delete 参数置于url
	axios.delete('/delete',{
		params:{
			id:200
		}
	}).then(res=>{
		console.log(res)
	})
	//delete 参数置于json
	axios({
		method:'delete',
		url:'/delete',
		params:{id:200}
	}).then(res=>{
		console.log(res)
	})
  }
}
</script>

<style>
</style>
